package com.x.provider.general.component;

import com.x.provider.api.common.enums.ItemTypeEnum;
import com.x.provider.api.customer.model.event.FollowEvent;
import com.x.provider.api.general.constants.GeneralEventTopic;
import com.x.provider.api.general.enums.ItemToggleRelationEnum;
import com.x.provider.api.general.enums.ItemToggleRelationTypeEnum;
import com.x.provider.api.general.model.dto.cms.StarSaveReqDTO;
import com.x.provider.api.general.model.event.ItemToggleRelationEvent;
import com.x.provider.general.service.cms.StarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class GeneralKafkaConsumer {

    private final StarService starService;

    public GeneralKafkaConsumer(StarService starService){
        this.starService = starService;
    }

//    @KafkaListener(topics = GeneralEventTopic.TOPIC_NAME_ITEM_TOGGLE_RELATION)
//    public void onFollowEvent(ItemToggleRelationEvent event) {
//        if (ItemToggleRelationTypeEnum.STAR.getValue().equals(event.getRelationType()) && ItemTypeEnum.CUSTOMER.getValue() == event.getFromItemType()){
//            starService.star(StarSaveReqDTO.builder().starCustomerId(event.getFromItemId()).itemType(event.getToItemType()).itemId(event.getToItemId())
//                    .star(ItemToggleRelationEnum.to(event.getRelation())).firstStar(event.isFirstRelation()).build());
//        }
//    }
}
